{include file="common:teacherheader" /}
{include file="common:teacherside" /}
    <div id="page-wrapper">
      <!-- 舆情日报 -->
      <!--*************************** content部分开始 ******************-->
      <div class="container-fluid" id="m_main">
        <div class="row m-t-20">
          <div class="col-sm-12">
            <div class="white-box">
              <h2 class="box-title m-b-20">课件管理</h2>
              <div class="row">
                <div class="col-sm-3">
                  <div class="form-group">
                    <div class="input-group">
                      <input type="text" class="form-control" id="name" value="" placeholder="请输入课件主题">
                    </div>
                  </div>
                </div>
                <div class="di fl p-l-15 m-r-30">
                  <div class="form-group">
                    <div class="botton-box">
                      <div class="btn-group">
                        <button class="btn btn-outline btn-primary p-l-34 p-r-34" @click="search(1)">查询</button>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="white-box">
              <div class="table-responsive">
                <table id="myTable" class="table table-striped color-table">
                  <thead>
                    <tr>
                      <!-- <th>课件序号</th> -->
                      <th>课件名称</th>
                      <!-- <th>课件类型</th> -->
                      <th>课件主题</th>
                      <!-- <th>课件内容</th> -->
                      <th>添加时间</th>
                      <th>操作</th>
                    </tr>
                  </thead>
                  <tbody>
                    <tr v-for="(item,index) in dataList">
                      <!-- <td>{{item.course_id}}</td> -->
                      <td>{{item.name}}</td>
                      <!-- <td>{{item.type}}</td> -->
                      <td>{{item.course}}</td>
                      <!-- <td>{{item.content}}</td> -->
                      <td>{{item.create_date}}</td>
                      <td>
                        <div>
                          <a target="_blank" :href="'/dboard/teacheradmin/edit_courseware?id=' + item.id" class="info m-r-15">查看</a>
                          <!-- <a :href="item.file" class="info m-r-15">下载</a> -->
                        </div>
                      </td>
                    </tr>
                  </tbody>
                </table>
                <pagination :tr-all="trAll" :page-cur="pageCur" :page-all="pageAll" :page-size="pageSize" @page-to="pageTo" ref="c1"></pagination>
              </div>
              <!-- 确认取消提示框 -->
              <confirm  class="modal fade" id="confirm1" tabindex="-1" role="dialog" :confirm-msg="confirmMsg" :edit-id="delId" @yes-btn="deleteItem"></confirm>
            </div>
          </div>
        </div>

        <!-- /.row -->
      </div>
      <!--*************************** content部分结束 ******************-->

      <!-- <footer class="footer text-center"> 2017 &copy; Ample Admin brought to you by themedesigner.in </footer> -->
    </div>
  {include file="common:js" /}
  {include file="common:footer" /}
  <script type="text/javascript" src="/web/js/search_list.js"></script>
  {include file="component:pagination" /}
  {include file="component:confirm" /}

  <script type="text/javascript">
    var vm = new Vue({
      el: '#m_main',
      data() {
        return {
          searchUrl: "/dboard/teacheradmin/courseware_lists", //搜索接口
          draw: '', //校验字段
          dataList: [], //搜索列表数据
          trAll: 0, //数据总数
          pageAll: 0, //页码总数
          pageCur: 1, //当前页
          pageSize: 10, //每页数量
          delUrl: '/dboard/course/updateCourse', //删除请求接口
          confirmMsg: '删除当前课程信息？', //confirm提示框内容
          delId: undefined, //当前删除的id
          sid: '{$sid}',
          course_id: '',
        }
      },
      mounted() {
      
        var url = decodeURI(location.search); //获取url中"?"符后的字串
        var course_id= url.split('=')[1];
        this.course_id = course_id;
        this.pageTo(1,course_id);
       console.log(course_id)
      },
      
      methods: {
        // 搜索当前页并渲染列表
        pageTo(page) {
          var that = this;
          var params = { sid: that.sid,course_id: that.course_id };
          searchList(that, page, params, (res) => {
            that.dataList = res.data.Data.Data;
          }, (fail) => {}, (error) => {})
        },
        // 删除当前记录
        deleteItem(){
          var that = this;
          var params = {
            cid:that.delId
          };
          deleteLine(that,params,(res)=>{},(fail)=>{},(err)=>{});
        },
        search(page) {
          var that = this;
          var name = $('#name').val();
          var params = { sid: that.sid,name:name,course_id:that.course_id };
          searchList(that, page, params, (res) => {
            console.log(res)
            that.dataList = res.data.Data.Data;
          }, (fail) => {}, (error) => {})
        },
      }
    })
    
  </script>
